package com.zeedev.flyingsaucer.beers.activities.beerdialog;

import android.app.Activity;
import android.database.Cursor;
import com.google.inject.Provides;
import com.google.inject.name.Named;
import com.zeedev.provider.FlyingSaucer;
import mobi.zeedev.flyingsaucer.common.DataModule.FlyingSaucerConv;
import mobi.zeedev.flyingsaucer.common.DataModule.MetaBeer;
import mobi.zeedev.flyingsaucer.common.DataModule.Util;
import roboguice.config.AbstractAndroidModule;

/**
 * User: James
 * Date: 1/2/11
 * Time: 12:47 AM
 */
public class BeerDialogModule extends AbstractAndroidModule {

    @Override
    protected void configure() {
//        bind(BeerDialogController.class).annotatedWith(BeerDialog.class).to(BeerDialogControllerImpl.class);
//        bind(BeerDialogModel.class);

    }

    @Provides
    @Named(MetaBeer.BEER_ID)
    Integer providesBeerId(Activity mActivity) {
        return mActivity.getIntent().getIntExtra(MetaBeer.BEER_ID, -1);
    }

    @Provides
    @Named("dialogCursor")
    Cursor provideDialogCursor(Activity mActivity) {
        Integer beerId = mActivity.getIntent().getIntExtra(FlyingSaucer.Beers.BEER_ID, 0);
//        Cursor mCursor = mActivity.getContentResolver().query()
//        mActivity.startManagingCursor();
        Cursor mCursor = mActivity.managedQuery(FlyingSaucerConv.Beers.CONTENT_URI, null, FlyingSaucerConv.Beers.BEER_ID + "=?", Util.asAr(beerId), null);
        return mCursor;
    }


}
